<%-- 
    Document   : KirimAkhir
    Created on : Nov 30, 2013, 5:31:16 PM
    Author     : AG.DIMAS.F
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<script>function validate(evt) {
        var theEvent = evt || window.event;
        var key = theEvent.keyCode || theEvent.which;
        key = String.fromCharCode(key);
        var regex = /[0-9\b\t]|\./;
        if (!regex.test(key)) {
            theEvent.returnValue = false;
            if (theEvent.preventDefault)
                theEvent.preventDefault();
        }
    }</script> 

<script>
    function displayResult()
    {
        var x = document.getElementById("tarifBarang").value;
        var y = document.getElementById("beratBarang").value;
        var z = x * y;
        document.getElementById("hargaBarang").value = z;
    }
</script>
<% String cab = "";
    if ("agen1".equals(session.getAttribute("area"))) {
        cab = "AGEN A";
    }
    if ("agen2".equals(session.getAttribute("area"))) {
        cab = "AGEN B";
    }
    if ("agen3".equals(session.getAttribute("area"))) {
        cab = "AGEN C";
    }
%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head> 
    <body> 
        <input type="hidden" name="area" value="<%=session.getAttribute("area")%>" />
    
        <h4 align="right" class="header"><strong>Selamat Datang, <%= session.getAttribute("user")%>
                <br>  <a href="FormLogin.jsp" >Logout</a>
            </strong></h4> <br>
                <h4 align="center"> <a href='HalamanUtama.jsp'>Halaman Utama</a></h4><br>
        <form action="kontrolBarang">
            <table>
                <tr><td><b><font size ='5' color='FF0000' face= 'Papyrus'><b><i>  Data Barang </i>  </b></font></td><td></td><td></td><td></td><td><b><font size ='5' color='FF0000' face= 'Papyrus'><b><i>  Identitas Pengirim  </i></b></font></td>
                </tr>
                <tr><td>Tanggal kirim </td><td>:</td>
                    <td><select name="tanggal">
                            <% for (int i = 1; i <= 31; i++) {%>
                            <option value=<%=i%> ><%=i%></option>
                            <%}%></select>

                        <select name="bulan">
                            <option value="JAN">January</option>
                            <option value="FEB">February</option>
                            <option value="MAR">March</option>
                            <option value="APR">April</option>
                            <option value="MAY">May</option>
                            <option value="JUN">June</option>
                            <option value="JUL">July</option>
                            <option value="AUG">August</option>
                            <option value="SEP">September</option>
                            <option value="OCT">October</option>
                            <option value="NOV">November</option>
                            <option value="DEC">December</option>
                        </select>

                        <select name="tahun">
                            <% for (int i = 1999; i <= 2020; i++) {%>
                            <option value=<%=i%> ><%=i%></option>

                            <%}%></select>


                    </td><td></td><td>Nama</td><td>:</td><td><input type="text" name="namaPengirim"/></td></tr>
                <tr><td>Kode Resi</td><td>:</td><td><input type="text" name="kodeResi" /></td><td></td>
                    <td>Alamat</td><td>:</td><td><input type="text" name="alamatPengirim" /></td></tr>
                <tr><td>Nama Barang</td><td>:</td><td><input type="text" name="namaBarang" value=""/></td><td></td>
                    <td>No.Telp/HP</td><td>:</td><td><input type="text" name="tlpPengirim" value=""/></td></tr>
                <tr><td>Jenis Barang</td><td>:</td><td><input type="text" name="jenisBarang" value=""/></td><td></td>
                    <td><b><font size ='5' color='FF0000' face= 'Papyrus'><b><i>  Identitas Penerima  </i></b></font></td></tr>
                <tr><td>Agen Tujuan</td><td>:</td><td><select name="kotaTujuan">
                            <% if ("agen1".equals(session.getAttribute("area"))) {
                            %> <option value="agen2">AGEN B</option>
                            <option value="agen3">AGEN C </option>

                            <%}
                                if ("agen2".equals(session.getAttribute("area"))) {
                            %> <option value="agen1">AGEN A </option>  
                            <option value="agen3">AGEN C </option>
                            <%  }
                                if ("agen3".equals(session.getAttribute("area"))) {%>
                            <option value="agen1">AGEN A </option>
                            <option value="agen2">AGEN B </option>
                            <%                                }%>
                        </select></td> <td></td>
                    <td>Nama</td><td>:</td><td><input type="text" name="namaPenerima" value=""/></td></tr>
                <tr><td>Agen Asal</td><td>:</td><td>
                        <input type="text" name="kotaAsal" readonly="" value="<%=cab%>" /></td><td></td>
                    <td>Alamat</td><td>:</td><td><input type="text" name="alamatPenerima" value=""/></td></tr>
                <tr><td>Tarif/kg</td><td>:</td><td><input type="text" id="tarifBarang" value="" onkeypress='validate(event)' name="tarifBarang"/></td><td></td>
                    <td>No.Telp/HP</td><td>:</td><td><input type="text" name="tlpPenerima" value=""/></td></tr>
                <tr> <td>Berat Barang</td><td>:</td><td><input type="text" id="beratBarang" value="" onkeypress='validate(event)' name="beratBarang"/></td></tr>
                <tr><td>Harga</td><td>:</td><td><input id="hargaBarang" type="text" value="" name="hargaBarang"  readonly="" />
                        <input type="button" onclick="displayResult()" value="Lihat Harga"  /></td></tr>
                <tr><td>Keterangan</td><td>:</td><td><input type="text" name="keteranganBarang" value=""/></td></tr>
                <tr><td></td><td></td><td></td><td> <td> <input  type="submit" value="Kirim">   <input type="reset" value="Batal"></td> </tr>
            </table>
        </form>
    </body>
</html>
